package com.zbkj.front.controller.mszs;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsPlatformAccountRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsPlatformAccountResponse;
import com.zbkj.service.service.mszs.MszsPlatformAccountSevice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description 平台账号表-controller层
 * @author JIANTAO
 */
@RestController
@RequestMapping(value = "api/front/mszs/platform")
@Slf4j
@Api(tags = "民宿助手-平台账号管理")
public class MszsPlatformAccountController {

    @Resource
    private MszsPlatformAccountSevice accountSevice;

    @ApiOperation(value="新增-平台账号")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsPlatformAccountRequest request){
        return CommonResult.success(accountSevice.insert(request));
    }
    @ApiOperation(value="修改-平台账号")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsPlatformAccountRequest request){
        return CommonResult.success(accountSevice.update(request));
    }

    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> del(@RequestParam("id")Integer id){
        return CommonResult.success(accountSevice.delete(id));
    }

    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsPlatformAccountResponse> load(@RequestParam("id") Integer id) {
        return CommonResult.success(accountSevice.load(id));
    }

    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsPlatformAccountResponse>> pageList(
            @Validated String title,
            @Validated String jdId,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsPlatformAccountResponse> mszsOrderPage = CommonPage.restPage(accountSevice.pageList(title,jdId,pageParamRequest));
        return CommonResult.success(mszsOrderPage);
    }


}
